package com.ttxs.common.core.exception;

import com.ttxs.common.core.vo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public R globalException(Exception exception) {
        log.error("Global Exception Handler: {}, {}", exception.getClass(), exception.getMessage(), exception);
        return R.error(exception.getMessage());
    }

}
